#include<string.h>
#include<stdio.h>
#include<errno.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<stdlib.h>

int main()
{
    pid_t id=fork();
    
    if(id==0)
    {
        char * const env[]=
        {
            "HELLO=ECECL",
            "PATH=./",
            NULL
        };
         char * const argv[]=
        {
            "ls",
            "-a",
            "-l",
            NULL
        };
        execv("/usr/bin/ls",argv);
        //execle("./myhello","myhello",NULL,env);
        // execl("./myhello","myhello",NULL);
       //execlp("myhello","myhello",NULL);
       exit(123);
    }
    else
    {
        int status=0;
        pid_t rid=wait(&status);
        while(1)
        {
            sleep(1);
             printf("子进程退出码为%d\n",WEXITSTATUS(status));
        }
    }

    return 0;
}
